import 'package:flutter/material.dart';

class ImagePage extends StatefulWidget {
  @override
  _ImagePageState createState() => new _ImagePageState();
}

class _ImagePageState extends State<ImagePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Image"),
      ),
      body: _buildListView(),
    );
  }

  Widget _buildListView() {
    return ListView.builder(
      itemBuilder: (context, index) {
        return _buildListViewItem(index);
      },
      itemCount: containers.length,
    );
  }

  Widget _buildListViewItem(index) {
    return Container(
      padding: EdgeInsets.all(10.0),
      alignment: Alignment.center,
      child: containers[index],
    );
  }
}

List<Widget> containers = <Widget>[
  Column(
    children: <Widget>[
      Text("Image asset"),
      Container(
        child: Image.asset(
          'assets/images/cat.jpeg',
          width: 300,
          height: 160,
        ),
      ),
    ],
  ),
  Column(
    children: <Widget>[
      Text("Image network"),
      Container(
        child: Image.network(
          'http://pic1.win4000.com/pic/c/cf/cdc983699c.jpg',
        ),
      ),
    ],
  ),
  Column(
    children: <Widget>[
      Text("Image SD"),
      Container(
        child: Image.network(
          'http://pic1.win4000.com/pic/c/cf/cdc983699c.jpg',
        ),
      ),
    ],
  ),
  Column(
    children: <Widget>[
      Text("Image fit fill"),
      Container(
        width: 400,
        height: 100,
        color: Colors.grey,
        child: Image.asset(
          'assets/images/cat.jpeg',
          fit: BoxFit.fill,
        ),
      ),
    ],
  ),
  Column(
    children: <Widget>[
      Text("Image fit contain"),
      Container(
        width: 400,
        height: 100,
        color: Colors.grey,
        child: Image.asset(
          'assets/images/cat.jpeg',
          fit: BoxFit.contain,
        ),
      ),
    ],
  ),
  Column(
    children: <Widget>[
      Text("Image fit cover"),
      Container(
        width: 400,
        height: 100,
        color: Colors.grey,
        child: Image.asset(
          'assets/images/cat.jpeg',
          fit: BoxFit.cover,
        ),
      ),
    ],
  ),
];
